package DoubleLinkedLlist;

import java.util.Iterator;
import java.util.LinkedList;

public class Test {
    public static void main(String[] args) {
        // 遍历链表
        LinkedList<Integer> list=new LinkedList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        System.out.println(list);
        System.out.println("========");

        // foreach 遍历
        for (Integer x:list) {
            System.out.print(x+" ");
        }
        System.out.println();
        System.out.println("========");

        // fori 遍历
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i)+" ");
        }
        System.out.println();
        System.out.println("========");

        // 迭代器遍历
        Iterator<Integer>  iterator=list.iterator();
        while(iterator.hasNext()){
            System.out.print(iterator.next()+" ");
        }
    }







    public static void main01(String[] args) {

        MyLinkList myLinkList=new MyLinkList();

        myLinkList.addFirst(5);
        myLinkList.addFirst(6);
        myLinkList.addFirst(4);
        myLinkList.addFirst(4);

        myLinkList.addLast(1);
        myLinkList.addLast(4);
        myLinkList.addLast(3);
        myLinkList.addLast(4);
        myLinkList.display();



       myLinkList.removeAllKey(4);
        myLinkList.display();

        myLinkList.clear();
        System.out.println("hello");
/*
        myLinkList.addIndex(5,9);

        myLinkList.display();

        System.out.println(myLinkList.contains(4));
    */
    }
}
